package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.entity.Employee;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface EmployeeMapper {

    /**
     * 根据用户名查询员工
     * @param username 员工姓名
     * @return 返回员工实体类
     */
    @Select("select * from employee where username = #{username}")
    Employee getByUsername(String username);

    /**
     * 分页查询员工
     * @param name 员工姓名
     * @return 返回分页数据
     */
    Page<Employee> pageQuery(String name);

    /**
     * 根据id查询员工
     * @param id 员工id
     * @return 员工实体类
     */
    @Select("select * from employee where id = #{id}")
    Employee selectById(Long id);

    /**
     * 新增员工
     * @param employee 员工实体类
     * @return
     */
    @AutoFill(OperationType.INSERT)
    void save(Employee employee);


    /**
     * 根据id更新员工
     * @param employee 员工实体类
     * @return
     */
    @AutoFill(OperationType.UPDATE)
    void update(Employee employee);
}
